<?php

class Core_Validate_NotMatch extends Zend_Validate_Abstract
{
	const MSG_NOTMATCH = 'notmatch';
	
	protected $_notmatch = '';
	protected $_prefix = '';
	
	protected $_messageVariables = array(
			'prefix' => '_prefix'
	);

	protected $_messageTemplates = array(
		self::MSG_NOTMATCH 	=> "Not allow match '%prefix%'",
	);
	
	public function __construct($notmatch = '', $prefix = '')
	{
		$this->_notmatch = $notmatch;
		$this->_prefix = empty($prefix)?(is_array($notmatch)?implode(', ', $notmatch):$notmatch):$prefix;
	}

	public function isValid($value)
	{
		$this->_setValue($value);

		if(($this->_notmatch == $value) || in_array($value, $this->_notmatch))
		{
			$this->_error(self::MSG_NOTMATCH);
		}
		
		return empty($this->_errors);
	}
}